<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<link rel="stylesheet" href="__PUBLIC__/Admin/css/bootstrap.min.css">
	<link rel="stylesheet" href="__PUBLIC__/Admin/css/adindex.css">
</head>
<body>
	<div class="panel panel-default">
		<div class="panel-heading">
		    <h3 class="panel-title" id="M1" style="float:left"><b>动态</b></h3>
	        <form class="form-inline"  style="float:left;margin-left:40px;" role="form">
	       		<span><b>筛选:</b></span>
	          <div class="checkbox"><label><input type="checkbox" value ="1">游记</label></div>
			  <div class="checkbox"><label><input type="checkbox" value="2">活动</label></div>
			  <div class="checkbox"><label><input type="checkbox" value="3">求助</label></div> 
			</form>
			<form class="form-inline"  style="float:right;margin-right:40px;" role="form">
	       		<span><b>发布类型:</b></span>
	       		<select name="" class="test" >
	       			<option value="0">选择</option>
	       			<option value="1">游记</option>
	       			<option value="2">活动</option>
	       			<option value="3">求助</option>
	       		</select>	    
			</form>
		    <br>
		    <br>
	    </div>
		 <if condition="$partners eq null">
			<div class="media" id="change" style="height:680px;padding:20% 20%" >
		    	<h2><b>没有任何消息哦!&nbsp;&nbsp; 
		   		<span class="glyphicon glyphicon-hand-right"></span>
		   		<a href="">速度添加我的伙伴圈</a></b></h2>
			</div>	
		<else/>
			<div id="change1">
				<foreach name='partners' item='part'>
				<if condition="$part['cat_id'] eq 1">
				<label><span class="glyphicon glyphicon-tags">游记类</span></label>
				<div class="media" style="height:145px;padding:10px;border-bottom:1px solid gray;">
				    <a class="pull-left" href="#">
				        <img class="media-object" src="{$part['img_path']}" style="width:200px;height: 100px">
				    </a>
				    <div class="media-body" >
				        <h4 class="media-heading"><b>{$part['title']}</b></h4>
						<p style="float:left;height:38px;margin-right:60px;text-indent:2em;overflow:hidden;text-overflow: ellipsis;display:-webkit-box; -webkit-line-clamp:2;-webkit-box-orient:vertical;">
						    {$part['content']}
						</p>	
						<div class="paperBottom" style="float:right;margin-top:30px;">
							<p>
								<span><i class="glyphicon glyphicon-camera"></i>{$part['area']}</span>
								<span><i class="glyphicon glyphicon-user"></i>By:{$part['partner_name']}</span>
								<span><i class="glyphicon glyphicon-eye-open"></i>&nbsp;&nbsp;{$part['click_num']}</span>&nbsp;&nbsp;
						        <button type="button" class="btn btn-default btn-sm">
						        	<span class="glyphicon glyphicon-thumbs-up">点赞</span>
						   		</button>&nbsp;&nbsp;
						   		<a href="{:U('Admin/Index/read',['id'=>$part['id']])}" target="_top">
						   			<button type="button" class="btn btn-default btn-sm">
						        		<span class="glyphicon glyphicon-road">查看</span>
						   			</button>
						   		</a>
						    </p>						
						</div>	  	      
					</div>
				</div>
				<elseif condition="$part['cat_id'] eq 2"/>
				<label><span class="glyphicon glyphicon-tags">活动类</span></label>
				<div class="media" style="height:145px;padding:10px;border-bottom:1px solid gray;">
				    <div class="media-body" >
				        <h4 class="media-heading"><b>{$part['title']}</b></h4>
						<p style="float:left;height:38px;margin-right:60px;text-indent:2em;overflow:hidden;text-overflow: ellipsis;display:-webkit-box; -webkit-line-clamp:2;-webkit-box-orient:vertical;">
						    {$part['content']}
						</p>	
						<div class="paperBottom" style="float:right;margin-top:30px;">
							<p>
								<span><i class="glyphicon glyphicon-camera"></i>{$part['area']}</span>
								<span><i class="glyphicon glyphicon-user"></i>By:{$part['partner_name']}</span>
								<span><i class="glyphicon glyphicon-eye-open"></i>&nbsp;&nbsp;{$part['click_num']}</span>&nbsp;&nbsp;
						        <button type="button" class="btn btn-default btn-sm">
						        	<span class="glyphicon glyphicon-thumbs-up">点赞</span>
						   		</button>&nbsp;&nbsp;
						   		<a href="{:U('Admin/Index/read',['id'=>$part['id']])}" target="_top">
						   			<button type="button" class="btn btn-default btn-sm">
						        		<span class="glyphicon glyphicon-road">查看</span>
						   			</button>
						   		</a>
						    </p>
						</div>	  	      
					</div>
				</div>
				<else />
				<label><span class="glyphicon glyphicon-tags">求助类</span></label>
				<div class="media" style="height:145px;padding:10px;border-bottom:1px solid gray;">
				    <div class="media-body" style="height:145px;">
				        <h4 class="media-heading"><b>{$part['title']}</b></h4>
						<p style="float:left;height:38px;margin-right:60px;text-indent:2em;overflow:hidden;text-overflow: ellipsis;display:-webkit-box; -webkit-line-clamp:3;-webkit-box-orient:vertical;">
						    {$part['content']}
						</p>	
						<div class="paperBottom" style="float:right;">
							<p>
								<span><i class="glyphicon glyphicon-camera"></i>{$part['area']}</span>
								<span><i class="glyphicon glyphicon-user"></i>By:{$part['partner_name']}</span>
								<span><i class="glyphicon glyphicon-eye-open"></i>&nbsp;&nbsp;{$part['click_num']}</span>&nbsp;&nbsp;
						   		<a href="{:U('Admin/Index/read',['id'=>$part['id']])}" target="_top">
						   			<button type="button" class="btn btn-default btn-sm">
						        		<span class="glyphicon glyphicon-road">查看</span>
						   			</button>
						   		</a>
						    </p>
						</div>	  	      
					</div>
				</div>
				</if>
				</foreach>
				<div class="media" style="margin-bottom: 50px;"></div>	
				<ul class="pagination" style="float:right;margin-right:40%;margin-top:-50px">
					{$page}
			   	</ul>
			</div>
		</if>
		<div id="change2" style="display:none;height:480px;">
				<form action="{:U('Index/travelAdd')}" method="post" class="inline-block" role="form" enctype="multipart/form-data" style="margin:20px 30px 80px 30px" target="_top">
					<div class="form-group">
						<label for="">游记标题:</label>
						<input type="text" class='form-control' name="title" placeholder="文章标题"><br>
						<small>副标题:</small>
				    	<input type="text" class="form-control" id="name" name="smtitle" placeholder="请输入名称" >
				    	<small>地点:</small>
					    	<input type="text" class="form-control" name="area" id="name" placeholder="地点" >
					</div>
				    <label for="name">游记内容</label>
				    <textarea class="form-control" rows="5" name="content" style="text-indent:2em"></textarea>
					<div class="form-group" id="up" name="pic" style="display:none">
						<input type="file" name="pic" id="inputfile" >
					</div>
					
				  	<div style="float:right;margin:20px"> 
						<span><b>权限:</b></span>&nbsp;
			       		<select name="power" id="">
			       			<option value="4">公开</option>
			       			<option value="5">伙伴</option>
			       			<option value="6">自己</option>
			       		</select>&nbsp;&nbsp;&nbsp;&nbsp;
				  		 <button type="button" class="btn btn-default btn-sm" onclick="inputfile.click()">晒图</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<input type="submit" id="v2" class="btn btn-default btn-sm" value="提交">&nbsp;&nbsp;&nbsp;&nbsp;
						<button type="button" class="btn btn-default btn-sm">重置</button>
						<input type="hidden"  name="cat_id" value="1">
					</div>
				</form>
		</div>
		<div id="change3" style="display:none;height:480px;">
				<form class="inline-block" role="form" style="margin:20px 30px 80px 30px" action="{:U('/admin/index/postActivity')}" method="post">
					<div class="form-group">
						<label for="">活动主题:</label>
						<input type="text" class='form-control' placeholder="文章标题" name="title"><br>
						<small>副标题:</small>
				    	<input type="text" class="form-control"  id="name" placeholder="请输入名称" name="smtitle">
				    	<small>地点:</small>
				    	<input type="text" class="form-control" name="area" placeholder="地点" >
					</div>
				    <label for="name">文本框</label>
				    <textarea class="form-control" rows="5" style="text-indent:2em" name="content"></textarea>
					<div class="form-group" id="up" style="display:none">
						<input type="file" id="inputfile" onchange="upfile.value=this.value">
					</div>
					<div id="friends" style="display: none;"></div>
				  	<div style="float:right;margin:20px"> 
				  		
					    <span id="invite" class="btn btn-default">邀请人员</span>

						<span><b>权限:</b></span>&nbsp;
			       		<select name="power" id="">
			       			<option value="4">公开</option>
			       			<option value="5">伙伴</option>
			       		</select>&nbsp;&nbsp;&nbsp;&nbsp;
						<button ype="button" class="btn btn-default btn-sm">提交</button>&nbsp;&nbsp;&nbsp;&nbsp;
						<button ype="button" class="btn btn-default btn-sm">重置</button>
						<!-- 隐藏域,发布分类 -->
						<input type="hidden"  name="cat_id" value="2">
						<!-- 隐藏域,发布类型 -->
					</div>
				</form>
		</div>
		<div  id="change4" style="display:none;height:480px;">
				<form action="{:U('Index/helpAdd')}" method="post"  class="inline-block" role="form" style="margin:20px 30px 80px 30px">
					<div class="form-group">
						<label for="">求助标题:</label>
						<input type="text" class='form-control'  name='title' placeholder="文章标题"><br>
						<small>地点:</small>
				    	<input type="text" class="form-control" name="area" id="name" placeholder="地点" >
				    	<small>电话:</small>
				    	<input type="number" class="form-control" bane="phone" id="name" placeholder="电话" >
					</div>
				    <label for="name">求助内容:</label>
				    <textarea name="content" class="form-control" rows="5" style="text-indent:2em"></textarea>
					<div class="form-group" id="up" style="display:none">
						<input type="file" id="inputfile" onchange="upfile.value=this.value">
					</div>
					
				  	<div style="float:right;margin:20px"> 
						<input type="submit" class="btn btn-default btn-sm" value="提交">&nbsp;&nbsp;&nbsp;&nbsp;
						<button type="button" class="btn btn-default btn-sm">重置</button>
						<!-- 隐藏域,发布分类 -->
						<input type="hidden"  name="cat_id" value="3">
						<input type="hidden"  name="power" value="4">
						<!-- 隐藏域,发布类型 -->
					</div>
				</form>
		</div>
	<div>
</body>
<script src="__PUBLIC__/Admin/js/jquery.min.js"></script>
<script src='__PUBLIC__/Admin/js/bootstrap.min.js'></script>
<script>
	var partners = $('input:checkbox');    //获取checkbox框的DOM对象
	//console.log(partners[0]);
	partners[0].click = function(){
		//alert(1);
		var xhr = new XMLHttpRequest();
		xhr.open('get',"{:U('index/partner',['nature'=>1])}")
		xhr.send(null);
		xhr.onreadystatechange = function(){
			//alert(1);
			console.log(this.readyState);
			if(this.readyState == 4){
				//return this.response;
			}
		}
	};
	$('.test').click(function(){
		console.log($('.test').val());
		if($('.test').val() == 0 ){
			//alert(1);
			//console.log($('.change1').css('display','block'));
			$('#change').show();
			$('#change1').show();
			$('#change2').hide();
			$('#change3').hide();
			$('#change4').hide();
		}
		if($('.test').val() == 1 ){
			//alert(1);
			$('#change').hide();
			$('#change1').hide();
			$('#change3').hide();
			$('#change4').hide();
			$('#change2').show();
		}
		if($('.test').val() == 2 ){
			//alert(1);
			$('#change').hide();
			$('#change1').hide();
			$('#change2').hide();
			$('#change4').hide();
			$('#change3').css('display','block');
		}
		if($('.test').val() == 3 ){
			//alert(1);
			$('#change').hide();
			$('#change1').hide();
			$('#change2').hide();
			$('#change3').hide();
			$('#change4').css('display','block');
		}
	});
	/**
	 * @author K.
	 * Ajax获取好友列表
	 */
	var tmp;//定义一个临时变量用于存放接收的JSON数据
	var length;//JSON数据长度
	$('#invite').click(function ()
		{
			var xhr = new XMLHttpRequest();
			xhr.onreadystatechange = function ()
			{
				if (this.readyState == 4) {
					tmp = xhr.responseText;
					tmp = JSON.parse(tmp);
					length = tmp.length;
					//遍历JSON对象
					for (var i in tmp) {
						$('#friends').append('<span><input type="checkbox" name="'+tmp[i].username+'" value="'+tmp[i].uid+'"/>'+tmp[i].username+'</span>');
						if (i == length - 1) {
							$('#friends').show();
						}
					}

				}
			}
			xhr.open('get', "{:U('/admin/index/getfriends')}", true);
			xhr.send(null);
		}
	);
</script>
</html>
	
